-
Notifications
You must be signed in to change notification settings - Fork 389
feat(fdc): Data Connect Bulk Import #2905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Refactors the previously added DataConnect CRUD helper methods (`insert`, `insertMany`, `upsert`, `upsertMany`) based on feedback. The core implementation logic (input validation, data serialization using `objectToString`, GraphQL mutation string construction, and calling `executeGraphql`) has been moved from the `DataConnect` class (`data-connect.ts`) to the `DataConnectApiClient` class (`data-connect-api-client-internal.ts`). The methods in the `DataConnect` class now act as simple pass-through delegates to the corresponding methods on the internal client instance. Unit tests have been updated accordingly: - Tests in `index.spec.ts` now verify the delegation from `DataConnect` to `DataConnectApiClient`. - New tests have been added to `data-connect-api-client-internal.spec.ts` to cover the implementation details within `DataConnectApiClient`. This change improves separation of concerns, keeping the public API surface (`DataConnect`) clean and concentrating the implementation details within the internal client.
test/unit/data-connect/data-connect-api-client-internal.spec.ts
Dismissed
Show dismissed
Hide dismissed
* Handles nested objects, arrays, strings, numbers, and booleans. | ||
* Ensures strings are properly escaped. | ||
*/ | ||
private objectToString(data: any): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this just be unknown
?
}); | ||
|
||
if (kvPairs.length === 0) { | ||
return '{}'; // Represent an object with no defined properties as {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure there's a case for when this would happen
if (validator.isArray(data)) { | ||
throw new FirebaseDataConnectError( | ||
DATA_CONNECT_ERROR_CODE_MAPPING.INVALID_ARGUMENT, | ||
'`data` must be an object, not an array, for single insert.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should help even more and say for arrays, please use "insertMany"
extras: [1, undefined, 'hello', undefined, { a: 1, b: undefined }] | ||
}; | ||
|
||
const tableNames = ['movie', 'Movie', 'MOVIE', 'toybox', 'toyBox', 'ToyBox', 'TOYBOX']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a case for mOvIE
?
Add new API interfaces for
insert
,insertMany
,upsert
,upsertMany
operations.